.class public Lcom/nemustech/regina/widgets/appointment/AppointmentDB;
.super Ljava/lang/Object;
.source "AppointmentDB.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;,
        Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;
    }
.end annotation


# static fields
.field private static final ANDROID_CALENDAR_URI:Ljava/lang/String; = "content://calendar/"

.field private static final ANDROID_CALENDAR_URI_2:Ljava/lang/String; = "content://com.android.calendar/"

.field private static final COJ_AND:Ljava/lang/String; = " AND "

.field private static final CON_SELECTED:Ljava/lang/String; = "selected=1"

.field private static final FLD_ALLDAY:Ljava/lang/String; = "allday"

.field private static final FLD_DTBEGIN:Ljava/lang/String; = "begin"

.field private static final FLD_DTEND:Ljava/lang/String; = "end"

.field private static final FLD_DTSTART:Ljava/lang/String; = "dtstart"

.field private static final FLD_ID:Ljava/lang/String; = "_id"

.field private static final FLD_NAME:Ljava/lang/String; = "name"

.field private static final FLD_TITLE:Ljava/lang/String; = "title"

.field private static final PATH_CALENDARS:Ljava/lang/String; = "calendars"

.field private static final PATH_EVENTS:Ljava/lang/String; = "events"

.field private static final PATH_INSTANCES:Ljava/lang/String; = "instances"

.field private static final TAG:Ljava/lang/String; = "AppointmentDB"


# instance fields
.field private mActivity:Landroid/app/Activity;

.field private mCalendars:Ljava/util/LinkedList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Landroid/app/Activity;)V
    .locals 1
    .parameter "activity"

    .prologue
    .line 77
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 78
    iput-object p1, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mActivity:Landroid/app/Activity;

    .line 79
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mCalendars:Ljava/util/LinkedList;

    .line 80
    return-void
.end method

.method private dump(Landroid/database/Cursor;I)V
    .locals 5
    .parameter "cursor"
    .parameter "index"

    .prologue
    .line 295
    invoke-interface {p1}, Landroid/database/Cursor;->getColumnCount()I

    move-result v0

    .line 296
    .local v0, columnCount:I
    const-string v2, "AppointmentDB"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "** Record["

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, "] Start **"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 297
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    if-ge v1, v0, :cond_0

    .line 298
    const-string v2, "AppointmentDB"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    invoke-interface {p1, v1}, Landroid/database/Cursor;->getColumnName(I)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, ":"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-interface {p1, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 297
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 300
    :cond_0
    const-string v2, "AppointmentDB"

    const-string v3, "** Record End **"

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 301
    return-void
.end method

.method private prvAddAppointment(Ljava/util/LinkedList;Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;)V
    .locals 7
    .parameter
    .parameter "newAppt"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;",
            ">;",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;",
            ")V"
        }
    .end annotation

    .prologue
    .line 234
    .local p1, array:Ljava/util/LinkedList;,"Ljava/util/LinkedList<Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;>;"
    invoke-virtual {p1}, Ljava/util/LinkedList;->size()I

    move-result v2

    .line 237
    .local v2, count:I
    invoke-virtual {p2}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;->getBeginTime()J

    move-result-wide v0

    .line 239
    .local v0, beginTime:J
    const/4 v3, 0x0

    .local v3, i:I
    :goto_0
    if-ge v3, v2, :cond_0

    .line 241
    invoke-virtual {p1, v3}, Ljava/util/LinkedList;->get(I)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;

    .line 258
    .local v4, oldAppt:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;
    invoke-virtual {v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;->getBeginTime()J

    move-result-wide v5

    cmp-long v5, v5, v0

    if-lez v5, :cond_1

    .line 261
    .end local v4           #oldAppt:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;
    :cond_0
    invoke-virtual {p1, v3, p2}, Ljava/util/LinkedList;->add(ILjava/lang/Object;)V

    .line 262
    return-void

    .line 239
    .restart local v4       #oldAppt:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;
    :cond_1
    add-int/lit8 v3, v3, 0x1

    goto :goto_0
.end method

.method private prvGetCursor(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    .locals 9
    .parameter "uriString"
    .parameter "fields"
    .parameter "selection"
    .parameter "path"

    .prologue
    const/4 v8, 0x0

    .line 267
    const/4 v7, 0x0

    .line 271
    .local v7, managedCursor:Landroid/database/Cursor;
    :try_start_0
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    .line 272
    .local v1, uriCalendars:Landroid/net/Uri;
    if-eqz v1, :cond_0

    .line 273
    iget-object v2, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mActivity:Landroid/app/Activity;

    invoke-virtual {v2}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    .line 274
    .local v0, cr:Landroid/content/ContentResolver;
    const/4 v4, 0x0

    const/4 v5, 0x0

    move-object v2, p2

    move-object v3, p3

    invoke-virtual/range {v0 .. v5}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v7

    .line 290
    .end local v0           #cr:Landroid/content/ContentResolver;
    :cond_0
    const-string v2, "AppointmentDB"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "cursor = "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    move-object v2, v7

    .line 291
    .end local v1           #uriCalendars:Landroid/net/Uri;
    :goto_0
    return-object v2

    .line 285
    :catch_0
    move-exception v2

    move-object v6, v2

    .line 286
    .local v6, e:Ljava/lang/Exception;
    const-string v2, "AppointmentDB"

    const-string v3, "managedQuery() exception..."

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    move-object v2, v8

    .line 287
    goto :goto_0
.end method

.method private setAppointmentsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;JII)V
    .locals 20
    .parameter "cursor"
    .parameter
    .parameter "start"
    .parameter "days"
    .parameter "utcOffset"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/database/Cursor;",
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;",
            ">;JII)V"
        }
    .end annotation

    .prologue
    .line 194
    .local p2, arrayAppointment:Ljava/util/LinkedList;,"Ljava/util/LinkedList<Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;>;"
    if-eqz p1, :cond_1

    invoke-interface/range {p1 .. p1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v4

    if-eqz v4, :cond_1

    .line 202
    const-string v4, "title"

    move-object/from16 v0, p1

    move-object v1, v4

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v17

    .line 203
    .local v17, colTitle:I
    const-string v4, "begin"

    move-object/from16 v0, p1

    move-object v1, v4

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v13

    .line 204
    .local v13, colDtBegin:I
    const-string v4, "dtstart"

    move-object/from16 v0, p1

    move-object v1, v4

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v15

    .line 205
    .local v15, colDtStart:I
    const-string v4, "end"

    move-object/from16 v0, p1

    move-object v1, v4

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v14

    .line 206
    .local v14, colDtEnd:I
    const-string v4, "allday"

    move-object/from16 v0, p1

    move-object v1, v4

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v16

    .line 210
    .local v16, colIsAllDay:I
    :cond_0
    move-object/from16 v0, p1

    move/from16 v1, v17

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    .line 211
    .local v5, title:Ljava/lang/String;
    move-object/from16 v0, p1

    move v1, v13

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v6

    .line 212
    .local v6, dtBegin:J
    move-object/from16 v0, p1

    move v1, v15

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v8

    .line 213
    .local v8, dtStart:J
    move-object/from16 v0, p1

    move v1, v14

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v10

    .line 214
    .local v10, dtEnd:J
    move-object/from16 v0, p1

    move/from16 v1, v16

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    const/4 v12, 0x1

    if-ne v4, v12, :cond_2

    const/4 v4, 0x1

    move v12, v4

    .line 216
    .local v12, isAllday:Z
    :goto_0
    if-eqz v12, :cond_3

    .line 217
    move/from16 v0, p6

    int-to-long v0, v0

    move-wide/from16 v18, v0

    sub-long v8, v8, v18

    .line 218
    move/from16 v0, p6

    int-to-long v0, v0

    move-wide/from16 v18, v0

    sub-long v6, v6, v18

    .line 219
    move/from16 v0, p6

    int-to-long v0, v0

    move-wide/from16 v18, v0

    sub-long v10, v10, v18

    .line 220
    cmp-long v4, v10, p3

    if-gez v4, :cond_3

    .line 227
    :goto_1
    invoke-interface/range {p1 .. p1}, Landroid/database/Cursor;->moveToNext()Z

    move-result v4

    if-nez v4, :cond_0

    .line 230
    .end local v5           #title:Ljava/lang/String;
    .end local v6           #dtBegin:J
    .end local v8           #dtStart:J
    .end local v10           #dtEnd:J
    .end local v12           #isAllday:Z
    .end local v13           #colDtBegin:I
    .end local v14           #colDtEnd:I
    .end local v15           #colDtStart:I
    .end local v16           #colIsAllDay:I
    .end local v17           #colTitle:I
    :cond_1
    return-void

    .line 214
    .restart local v5       #title:Ljava/lang/String;
    .restart local v6       #dtBegin:J
    .restart local v8       #dtStart:J
    .restart local v10       #dtEnd:J
    .restart local v13       #colDtBegin:I
    .restart local v14       #colDtEnd:I
    .restart local v15       #colDtStart:I
    .restart local v16       #colIsAllDay:I
    .restart local v17       #colTitle:I
    :cond_2
    const/4 v4, 0x0

    move v12, v4

    goto :goto_0

    .line 222
    .restart local v12       #isAllday:Z
    :cond_3
    new-instance v3, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;

    move-object/from16 v4, p0

    invoke-direct/range {v3 .. v12}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;-><init>(Lcom/nemustech/regina/widgets/appointment/AppointmentDB;Ljava/lang/String;JJJZ)V

    .line 226
    .local v3, appt:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;
    move-object/from16 v0, p0

    move-object/from16 v1, p2

    move-object v2, v3

    invoke-direct {v0, v1, v2}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->prvAddAppointment(Ljava/util/LinkedList;Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;)V

    goto :goto_1
.end method

.method private setCalendarsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;)V
    .locals 6
    .parameter "cursor"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/database/Cursor;",
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 127
    .local p2, calendars:Ljava/util/LinkedList;,"Ljava/util/LinkedList<Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;>;"
    if-eqz p1, :cond_1

    invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v5

    if-eqz v5, :cond_1

    .line 128
    const-string v5, "_id"

    invoke-interface {p1, v5}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v1

    .line 129
    .local v1, colID:I
    const-string v5, "name"

    invoke-interface {p1, v5}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v2

    .line 133
    .local v2, colName:I
    :cond_0
    invoke-interface {p1, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v3

    .line 134
    .local v3, id:I
    invoke-interface {p1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 135
    .local v4, name:Ljava/lang/String;
    new-instance v0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;

    invoke-direct {v0, p0, v3, v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;-><init>(Lcom/nemustech/regina/widgets/appointment/AppointmentDB;ILjava/lang/String;)V

    .line 136
    .local v0, calendar:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;
    invoke-virtual {p2, v0}, Ljava/util/LinkedList;->add(Ljava/lang/Object;)Z

    .line 137
    invoke-interface {p1}, Landroid/database/Cursor;->moveToNext()Z

    move-result v5

    if-nez v5, :cond_0

    .line 139
    .end local v0           #calendar:Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;
    .end local v1           #colID:I
    .end local v2           #colName:I
    .end local v3           #id:I
    .end local v4           #name:Ljava/lang/String;
    :cond_1
    return-void
.end method


# virtual methods
.method public getAppointments(JII)Ljava/util/LinkedList;
    .locals 19
    .parameter "start"
    .parameter "days"
    .parameter "utcOffset"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(JII)",
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;",
            ">;"
        }
    .end annotation

    .prologue
    .line 148
    new-instance v7, Ljava/util/LinkedList;

    invoke-direct {v7}, Ljava/util/LinkedList;-><init>()V

    .line 150
    .local v7, arrayAppointment:Ljava/util/LinkedList;,"Ljava/util/LinkedList<Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Appointment;>;"
    mul-int/lit8 v5, p3, 0x18

    const v6, 0x36ee80

    mul-int/2addr v5, v6

    int-to-long v8, v5

    add-long v8, v8, p1

    const-wide/16 v10, 0x1

    sub-long v14, v8, v10

    .line 151
    .local v14, dtend:J
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mActivity:Landroid/app/Activity;

    move-object v5, v0

    invoke-virtual {v5}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v13

    .line 152
    .local v13, cr:Landroid/content/ContentResolver;
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "instances/when/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    move-object v0, v5

    move-wide/from16 v1, p1

    invoke-virtual {v0, v1, v2}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v14, v15}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v17

    .line 154
    .local v17, path:Ljava/lang/String;
    const/4 v5, 0x5

    move v0, v5

    new-array v0, v0, [Ljava/lang/String;

    move-object/from16 v16, v0

    const/4 v5, 0x0

    const-string v6, "title"

    aput-object v6, v16, v5

    const/4 v5, 0x1

    const-string v6, "begin"

    aput-object v6, v16, v5

    const/4 v5, 0x2

    const-string v6, "dtstart"

    aput-object v6, v16, v5

    const/4 v5, 0x3

    const-string v6, "end"

    aput-object v6, v16, v5

    const/4 v5, 0x4

    const-string v6, "allday"

    aput-object v6, v16, v5

    .line 155
    .local v16, fields:[Ljava/lang/String;
    const-string v5, "content://calendar/"

    const/4 v6, 0x0

    const-string v8, "selected=1"

    move-object/from16 v0, p0

    move-object v1, v5

    move-object v2, v6

    move-object v3, v8

    move-object/from16 v4, v17

    invoke-direct {v0, v1, v2, v3, v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->prvGetCursor(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 156
    .local v6, cursor:Landroid/database/Cursor;
    const-string v5, "AppointmentDB"

    const-string v8, "try first"

    invoke-static {v5, v8}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 157
    if-eqz v6, :cond_1

    move-object/from16 v5, p0

    move-wide/from16 v8, p1

    move/from16 v10, p3

    move/from16 v11, p4

    .line 158
    invoke-direct/range {v5 .. v11}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->setAppointmentsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;JII)V

    .line 160
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "content://calendar/"

    invoke-virtual {v5, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    move-object v0, v5

    move-object/from16 v1, v17

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v18

    .line 161
    .local v18, uriCalendars:Landroid/net/Uri;
    if-eqz v18, :cond_0

    .line 162
    invoke-virtual/range {v18 .. v18}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v13, v5}, Landroid/content/ContentResolver;->acquireContentProviderClient(Ljava/lang/String;)Landroid/content/ContentProviderClient;

    move-result-object v12

    .line 163
    .local v12, cpc:Landroid/content/ContentProviderClient;
    if-eqz v12, :cond_0

    .line 164
    invoke-virtual {v12}, Landroid/content/ContentProviderClient;->release()Z

    .line 167
    .end local v12           #cpc:Landroid/content/ContentProviderClient;
    :cond_0
    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    .line 168
    const/4 v6, 0x0

    .line 171
    .end local v18           #uriCalendars:Landroid/net/Uri;
    :cond_1
    if-nez v6, :cond_3

    .line 172
    const-string v5, "AppointmentDB"

    const-string v6, "try second"

    .end local v6           #cursor:Landroid/database/Cursor;
    invoke-static {v5, v6}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 173
    const-string v5, "content://com.android.calendar/"

    const/4 v6, 0x0

    const-string v8, "selected=1"

    move-object/from16 v0, p0

    move-object v1, v5

    move-object v2, v6

    move-object v3, v8

    move-object/from16 v4, v17

    invoke-direct {v0, v1, v2, v3, v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->prvGetCursor(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 174
    .restart local v6       #cursor:Landroid/database/Cursor;
    if-eqz v6, :cond_3

    move-object/from16 v5, p0

    move-wide/from16 v8, p1

    move/from16 v10, p3

    move/from16 v11, p4

    .line 175
    invoke-direct/range {v5 .. v11}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->setAppointmentsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;JII)V

    .line 177
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "content://com.android.calendar/"

    invoke-virtual {v5, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    move-object v0, v5

    move-object/from16 v1, v17

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v18

    .line 178
    .restart local v18       #uriCalendars:Landroid/net/Uri;
    if-eqz v18, :cond_2

    .line 179
    invoke-virtual/range {v18 .. v18}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v13, v5}, Landroid/content/ContentResolver;->acquireContentProviderClient(Ljava/lang/String;)Landroid/content/ContentProviderClient;

    move-result-object v12

    .line 180
    .restart local v12       #cpc:Landroid/content/ContentProviderClient;
    if-eqz v12, :cond_2

    .line 181
    invoke-virtual {v12}, Landroid/content/ContentProviderClient;->release()Z

    .line 184
    .end local v12           #cpc:Landroid/content/ContentProviderClient;
    :cond_2
    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    .line 185
    const/4 v6, 0x0

    .line 189
    .end local v18           #uriCalendars:Landroid/net/Uri;
    :cond_3
    return-object v7
.end method

.method public getCalendars(Z)Ljava/util/LinkedList;
    .locals 9
    .parameter "selectedOnly"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(Z)",
            "Ljava/util/LinkedList",
            "<",
            "Lcom/nemustech/regina/widgets/appointment/AppointmentDB$Calendar;",
            ">;"
        }
    .end annotation

    .prologue
    .line 84
    iget-object v7, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mCalendars:Ljava/util/LinkedList;

    invoke-virtual {v7}, Ljava/util/LinkedList;->clear()V

    .line 86
    const-string v4, "calendars"

    .line 87
    .local v4, path:Ljava/lang/String;
    if-eqz p1, :cond_4

    const-string v7, "selected=1"

    move-object v5, v7

    .line 88
    .local v5, selection:Ljava/lang/String;
    :goto_0
    const/4 v7, 0x2

    new-array v3, v7, [Ljava/lang/String;

    const/4 v7, 0x0

    const-string v8, "_id"

    aput-object v8, v3, v7

    const/4 v7, 0x1

    const-string v8, "name"

    aput-object v8, v3, v7

    .line 89
    .local v3, fields:[Ljava/lang/String;
    iget-object v7, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mActivity:Landroid/app/Activity;

    invoke-virtual {v7}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    .line 91
    .local v1, cr:Landroid/content/ContentResolver;
    const-string v7, "content://calendar/"

    invoke-direct {p0, v7, v3, v5, v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->prvGetCursor(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v2

    .line 92
    .local v2, cursor:Landroid/database/Cursor;
    const-string v7, "AppointmentDB"

    const-string v8, "try first"

    invoke-static {v7, v8}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 93
    if-eqz v2, :cond_1

    .line 94
    iget-object v7, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mCalendars:Ljava/util/LinkedList;

    invoke-direct {p0, v2, v7}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->setCalendarsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;)V

    .line 95
    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "content://calendar/"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v7}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v6

    .line 96
    .local v6, uriCalendars:Landroid/net/Uri;
    if-eqz v6, :cond_0

    .line 97
    invoke-virtual {v6}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v1, v7}, Landroid/content/ContentResolver;->acquireContentProviderClient(Ljava/lang/String;)Landroid/content/ContentProviderClient;

    move-result-object v0

    .line 98
    .local v0, cpc:Landroid/content/ContentProviderClient;
    if-eqz v0, :cond_0

    .line 99
    invoke-virtual {v0}, Landroid/content/ContentProviderClient;->release()Z

    .line 102
    .end local v0           #cpc:Landroid/content/ContentProviderClient;
    :cond_0
    invoke-interface {v2}, Landroid/database/Cursor;->close()V

    .line 103
    const/4 v2, 0x0

    .line 106
    .end local v6           #uriCalendars:Landroid/net/Uri;
    :cond_1
    if-nez v2, :cond_3

    .line 107
    const-string v7, "AppointmentDB"

    const-string v8, "try second"

    invoke-static {v7, v8}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 108
    const-string v7, "content://com.android.calendar/"

    invoke-direct {p0, v7, v3, v5, v4}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->prvGetCursor(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v2

    .line 109
    if-eqz v2, :cond_3

    .line 110
    iget-object v7, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mCalendars:Ljava/util/LinkedList;

    invoke-direct {p0, v2, v7}, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->setCalendarsToLinkedList(Landroid/database/Cursor;Ljava/util/LinkedList;)V

    .line 111
    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "content://com.android.calendar/"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v7}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v6

    .line 112
    .restart local v6       #uriCalendars:Landroid/net/Uri;
    if-eqz v6, :cond_2

    .line 113
    invoke-virtual {v6}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v1, v7}, Landroid/content/ContentResolver;->acquireContentProviderClient(Ljava/lang/String;)Landroid/content/ContentProviderClient;

    move-result-object v0

    .line 114
    .restart local v0       #cpc:Landroid/content/ContentProviderClient;
    if-eqz v0, :cond_2

    .line 115
    invoke-virtual {v0}, Landroid/content/ContentProviderClient;->release()Z

    .line 118
    .end local v0           #cpc:Landroid/content/ContentProviderClient;
    :cond_2
    invoke-interface {v2}, Landroid/database/Cursor;->close()V

    .line 119
    const/4 v2, 0x0

    .line 123
    .end local v6           #uriCalendars:Landroid/net/Uri;
    :cond_3
    iget-object v7, p0, Lcom/nemustech/regina/widgets/appointment/AppointmentDB;->mCalendars:Ljava/util/LinkedList;

    return-object v7

    .line 87
    .end local v1           #cr:Landroid/content/ContentResolver;
    .end local v2           #cursor:Landroid/database/Cursor;
    .end local v3           #fields:[Ljava/lang/String;
    .end local v5           #selection:Ljava/lang/String;
    :cond_4
    const/4 v7, 0x0

    move-object v5, v7

    goto/16 :goto_0
.end method
